{*******************************************************************************
* The contents of this file are used with permission, subject to the Mozilla   *
* Public License Version 1.1 (the "License"); you may not use this file except *
* in compliance with the License. You may obtain a copy of the License at      *
* http://www.mozilla.org/MPL/                                                  *
*                                                                              *
* Software distributed under the License is distributed on an "AS IS" basis,   *
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *
* the specific language governing rights and limitations under the License.    *
*                                                                              *
* The Original Code is distributed as part of the "mediate" product and is     *
* Copyright (C) @home media limited. All Rights Reserved.                      *
*                                                                              *
* Email: support@athomemedia.co.uk                                             *
* Web:   http://www.athomemedia.co.uk                                          *
*******************************************************************************}

unit WMPEffects;

interface

uses
	Windows, WMPLib_TLB;

const
	SA_BUFFER_SIZE = 1024;

	EFFECT_CANGOFULLSCREEN  = $00000001;   // can the effect go full screen?
	EFFECT_HASPROPERTYPAGE  = $00000002;   // does the effect have a property page?
	EFFECT_VARIABLEFREQSTEP = $00000004;   // should effect return frequency data with variable size steps?

type
	TimedLevel = record
		frequency : array [0..1, 0..SA_BUFFER_SIZE-1] of byte;
    waveform  : array [0..1, 0..SA_BUFFER_SIZE-1] of byte;
    state : integer;
    timeStamp : int64;
  end;

  IWMPEffects = interface(IUnknown)
  	['{D3984C13-C3CB-48e2-8BE5-5168340B4F35}']
    procedure Render(var pLevels : TimedLevel; hdc : HDC; var prc : TRect); safecall;

    // provides the no. channels, sample rate and title of the audio currently playing
    procedure MediaInfo(lChannelCount : longint; lSampleRate : longint; bstrTitle : WideString); safecall;

    // called to retrieive the capabilities of the effect (fullscreen? property page?, etc.)
    procedure GetCapabilities(var pdwCapabilities : DWORD); safecall;

    // retrieve the display title of the effect
    procedure GetTitle(var bstrTitle : WideString); safecall;

    // retrieve the title for a preset
    procedure GetPresetTitle(nPreset : LongInt; var bstrPresetTitle : WideString); safecall;

    // retrieve the number of presets this effect supports
    procedure GetPresetCount(var pnPresetCount : LongInt); safecall;

    // set / get the current preset
    procedure SetCurrentPreset(nPreset : LongInt); safecall;
    procedure GetCurrentPreset(var pnPreset : LongInt); safecall;

    // display the property page of the effect (if there is one)
    procedure DisplayPropertyPage(hwndOwner : HWND); safecall;

    // This method will be called when the effect is to start and stop full screen
    // rendering (if supported)
    procedure GoFullscreen(fFullScreen : BOOL); safecall;

    // This method will get called after a successful call to GoFullScreen to render
    // the effect.  Return failure from this method to signal loss of full screen.
    procedure RenderFullScreen(var pLevels : TimedLevel); safecall;
  end;

  IWMPEffects2 = interface(IWMPEffects)
  ['{695386EC-AA3C-4618-A5E1-DD9A8B987632}']
    // Called by Windows Media Player to provide visualization access to the
    // core Windows Media Player APIs.
    procedure SetCore(var pPlayer : IWMPCore); safecall;

    // Called by Windows Media Player to instantiate a visualization window
    procedure Create(hwndParent : HWND); safecall;

    // Called by Windows Media Player to destroy a visualization window
    // instantiated in the Create method.
    procedure Destroy; safecall;

    //Called by Windows Media Player to inform the visualization that a new
    //media item has been loaded.
    procedure NotifyNewMedia(var pMedia : IWMPMedia); safecall;

    // Called by Windows Media Player to pass window messages to a visualization.
    procedure OnWindowMessage(msg : UINT; WParam : WPARAM; LParam : LPARAM;
      var plResultParam : LRESULT); safecall;

    // Called by Windows Media Player to render a windowed visualization.
    procedure RenderWindowed(var pData : TimedLevel; fRequiredRender : BOOL); safecall;
  end;

implementation

end.
